/* mp_main.c -- Arquivo que contem a função main
 *
 * Copyright (C) 2008, Diogo F. S. Ramos <diogofsr@grad.icmc.usp.br>
 *                     Bruno Ribeiro de Oliveira
 *                     Arineiza Cristina Pinheiro
 *                     Tomas Grover
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>

#include "mp_core.h"
#include "mp_utils.h"

static char options[] =
{ "p:"	/* Porta do servidor */
  "s:"	/* Endereço do servidor */
  "h"	/* Help */
};

void
help()
{
    printf("Marco Polo -- Mapeando o MUNDO\n"
	   " -p  = Porta do Servidor\n"
	   " -s  = Endereço do Servidor\n"
	   " -h  = Esta mensagem\n");
}

int
main( int argc, char *argv[] )
{
    int c = 0;
    char * server = "localhost";
    char * port = "6665";

    /* Parse command line */
    while ((c = getopt (argc, argv, options)) != -1)
    {
	switch (c)
	{
	case 's':
	    server = optarg;
	    break;
	case 'p':
	    port = optarg;
	    break;
	case 'h':
	    help();
	    return 1;
	case'?':
	    help();
	    return 1;
	default:
	    abort ();
	}
    }

    mp_init( server, port );
    return EXIT_SUCCESS;
}
